<!-- 城市选择 -->
<template>
  <div>
     <city-header></city-header>
     <city-search :cities="cities"></city-search>
     <city-list :cities="cities" :hotCities="hotCities" :letter="letter"></city-list>
     <city-alphabat :cities="cities" @change="handleChange"></city-alphabat>
  </div>
</template>

<script>
import axios from 'axios'
import CityHeader from './components/header'
import CitySearch from './components/search'
import CityList from './components/list'
import CityAlphabat from './components/alphabat'
export default {
  data () {
    return {
      cities: {},
      hotCities: [],
      letter: ''
    }
  },
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabat
  },

  computed: {},

  methods: {
    handleChange (letter) {
      this.letter = letter
    },
    getCityInfo () {
      axios.get('/api/city.json').then(result => {
        result = result.data
        // console.log(result)
        if (result.ret && result.data) {
          var data = result.data
          this.cities = data.cities
          this.hotCities = data.hotCities
        }
      }, err => {
        console.log(err.message)
      })
    }
  },

  mounted () {
    this.getCityInfo()
  }
}

</script>
<style lang='stylus' scoped>
</style>
